﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Windows.Forms;

namespace Future.FormBase
{
    /// <summary>
    /// 模块主窗体接口
    /// </summary>
    public interface IModuleBase
    {
        ModuleID GetModuleID(); //获取模块编号
        /// <summary>
        /// 获取模块信息
        /// </summary>
        /// <returns></returns>
        ModuleInfo GetModuleInfo();
        MenuStrip GetModuleMenu();
        /// <summary>
        /// 模块主窗体容器
        /// </summary>
        /// <returns></returns>
        Control GetContainer();

        void InitButton();
        void InitMenu();
    }

    /// <summary>
    /// 模块编号
    /// </summary>
    public enum ModuleID
    {//模块名=编号 按编号排序
        None = 0,
        DepotManager = 2,
        SalesManager = 3,
        StocksManager = 5,
        FinanceManager = 4,
        DataCenter = 1,
    }

    /// <summary>
    /// 模块信息类
    /// </summary>
    public class ModuleInfo
    {
        private Assembly _ModuleAssembly = null;
        private ModuleID _ModuleID = ModuleID.None;
        private string _ModuleName = string.Empty;
        private string _ModuleFile = string.Empty;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="asm">程序集清单</param>
        /// <param name="id">模块ID</param>
        /// <param name="name">模块名称</param>
        /// <param name="file">模块文件名</param>
        public ModuleInfo(Assembly asm, ModuleID id, string name, string file)
        {
            _ModuleAssembly = asm;
            _ModuleID = id;
            _ModuleName = name;
            _ModuleFile = file;
        }

        /// <summary>
        /// 加载DLL文件后程序集指针
        /// </summary>
        public Assembly ModuleAssembly
        {
            get { return _ModuleAssembly; }
            set { _ModuleAssembly = value; }
        }

        /// <summary>
        /// 模块文件(*.dll)
        /// </summary>
        public string ModuleFile
        {
            get { return _ModuleFile; }
            set { _ModuleFile = value; }
        }

        /// <summary>
        /// 模块名称
        /// </summary>
        public string ModuleName
        {
            get { return _ModuleName; }
            set { _ModuleName = value; }
        }

        /// <summary>
        /// 模块编号
        /// </summary>
        public ModuleID ModuleID
        {
            get { return _ModuleID; }
            set { _ModuleID = value; }
        }
    }
}
